package xyz.erupt.jpa.task;

import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @author 黄锦贤
 * @version 1.0
 * @email 996842803@qq.com
 * @date 2022/8/26
 */
@Slf4j
public class FutureResult {
    private final List result;

    public FutureResult(List result) {
        this.result = result;
    }

    public int size() {
        return result.size();
    }

    public <T> T get(int i) {
        try {
            if (result.get(i) instanceof Exception) {
                throw (Exception) result.get(i);
            }
            return (T) result.get(i);
        } catch (Exception e) {
            log.error("FutureResult获取值错误!!!", e);
            return null;
        }
    }
}
